﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnlineMealOrdering.Domain.Base
{
    /// <summary>
    /// Bussiness exceptions occured within the domain
    /// </summary>
    public class DomainException : ApplicationException
    {
        /// <summary>
        /// User data, for keeping key-value information based on system basic type
        /// </summary>
        private IDictionary<string, object> _data = new Dictionary<string, object>();
        public new IDictionary<string, object> Data
        {
            get { return _data; }
            set { _data = value; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DomainException"/>  class.
        /// </summary>
        public DomainException() : base() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="DomainException"/> class with
        /// a specified error message.
        /// </summary>
        /// <param name="message">A message that describes the error.</param>
        public DomainException(string message) : base(message) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="DomainException"/> class with
        /// a specified error message.
        /// </summary>
        /// <param name="data">User data</param>
        /// <param name="message">A message that describes the error.</param>
        public DomainException(string message, IDictionary<string, object> data)
            : base(message)
        {
            Data = data;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DomainException"/> class with
        /// a specified message format and arguments.
        /// </summary>
        /// <param name="format">message format</param>
        /// <param name="args">message arguments</param>
        public DomainException(string format, params object[] args)
            : this(string.Format(format, args))
        { }

    }
}
